package com.ithema.controller;

import com.ithema.domain.Student;
import com.ithema.service.StudentService;
import com.ithema.utils.AgeUtil;

import java.text.ParseException;
import java.util.Scanner;

/*
    客服类:
        1. 接收用户请求
        2. 指挥业务员处理对应业务
        3. 将处理的结果响应给用户展示
 */
public class StudentController extends BaseStudentController{


    //封装一个方法: 键盘录入学生信息,封装学生对象并返回
    public Student getStudentInfo(String id) {
        try {
            System.out.println("请输入学生姓名:");
            String name = sc.next();
            System.out.println("请输入学生出生日期:");
            String birthday = sc.next();
            //调用工具类,计算年龄
            String age = AgeUtil.getAge(birthday);

            //2. 封装学生对象
            Student stu = new Student();
            stu.setId(id);
            stu.setName(name);
            stu.setAge(age);
            stu.setBirthday(birthday);
            return stu;

        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
